﻿#include "assist_cross_tip.h"
#include <QPalette>

AssistCrossTipWidget::AssistCrossTipWidget(QWidget *parent, Qt::WindowFlags f)
    : QWidget(parent)
{
	//设置标签悬浮在最上层 无边框
    setWindowFlags(Qt::FramelessWindowHint);
    setAttribute(Qt::WA_TranslucentBackground, true);
    setAutoFillBackground(true);
    QPalette my_palette;
    my_palette.setColor(QPalette::Background, QColor(0, 0, 0, 0)); // 最后一项为透明度  
    setPalette(my_palette);
}

void AssistCrossTipWidget::SetPixmap(QPixmap pixmap)
{
    pixmap_ = pixmap;
}

void AssistCrossTipWidget::paintEvent(QPaintEvent *event)
{
    if (this->isVisible())
    {
        QPainter painter(this);
        painter.setOpacity(0.5);//透明度设置
        painter.drawPixmap(QPoint(0, 0), pixmap_);
    }
}
